function goToNextPage(paginationType, preActionUrl, actionUrl, targetObjId, goToNextPageMethod, totalSize, pageSize, nextPage, chkArrayList, chkAllObjId, chkObjName){
	var currentPage = $("#" + targetObjId + " #currentPage_" + targetObjId ).val();
	var prevPage = currentPage;
	var totalPage = Math.ceil(totalSize / pageSize);
	
	switch(goToNextPageMethod){
		case "firstPage":
			currentPage = 1;
		break;
		case "prevPage":
			if(Number(currentPage) - 1 < 1){
				currentPage = 1;
			}else{
				currentPage--;
			}
		break;
		case "nextPage":
			if(Number(currentPage) + 1 < totalPage){
				currentPage++;
			}else{
				currentPage = totalPage;
			}
		break;
		case "lastPage":
			currentPage = totalPage;
		break;
		case "numberPage":
			if(nextPage < 1){
				currentPage = 1;
			}else if(nextPage > totalPage){
				currentPage = totalPage;
			}else{
				currentPage = nextPage;
			}
		break;
		default:
		//執行非以上情況
	}
	
	if(paginationType == 'normal'){
		goToNextPageByNormal(targetObjId, totalSize, pageSize, totalPage, prevPage, currentPage, chkAllObjId, chkObjName);
	}else if(paginationType == 'ajax'){
		goToNextPageByAJAX(targetObjId, actionUrl, totalSize, pageSize, totalPage, prevPage, currentPage, chkArrayList, chkAllObjId, chkObjName);
	}

}

function goToNextPageByNormal(targetObjId, totalSize, pageSize, totalPage, prevPage, currentPage, chkAllObjId, chkObjName){
	var oldStartPageNo = (Number(prevPage) - 1) * Number(pageSize);
	var oldEndPageNo = Number(oldStartPageNo) + Number(pageSize) - 1;
	//alert("oldStartPageNo = " + oldStartPageNo + ", oldEndPageNo = " + oldEndPageNo);
	for(var i = oldStartPageNo; i <= oldEndPageNo; i++){
		$("#" + targetObjId + " #tr_" + targetObjId + "_" + i).css("display", "none");
	}
	
	//$("tr[name='tr_" + targetObjId + "']:visible").css("display", "none");
	var newStartPageNo = (Number(currentPage) - 1) * Number(pageSize);
	var newEndPageNo = Number(newStartPageNo) + Number(pageSize) - 1;
	if(newEndPageNo > totalSize){
		newEndPageNo = totalSize;
	}
	//alert("newStartPageNo = " + newStartPageNo + ", newEndPageNo = " + newEndPageNo);
	for(var i = newStartPageNo; i <= newEndPageNo; i++){
		$("#" + targetObjId + " #tr_" + targetObjId + "_" + i).css("display", "");
	}
	
	refreshPaginationContent(targetObjId, totalSize, pageSize, totalPage, currentPage);
	refreshChkAll("normal", targetObjId, chkAllObjId, chkObjName);
	updateUrl(targetObjId, currentPage, pageSize);
}

function goToNextPageByAJAX(targetObjId, actionUrl, totalSize, pageSize, totalPage, currentPage, nextPage, chkArrayList, chkAllObjId, chkObjName){
	$.ajax({                                                 
		type: "POST",
		datatype:"html",    
		url: actionUrl,                      
		data: $("#qryCondition_" + targetObjId).val() + '&' + $.param({pageSize:pageSize, currentPage:currentPage, nextPage:nextPage}),
	    success: function(result){
	    		$("#" + targetObjId).html(result);
	    		refreshPaginationContent(targetObjId, totalSize, pageSize, totalPage, nextPage);
	    		refreshChk("ajax", targetObjId, chkArrayList, chkAllObjId, chkObjName);
	    		updateUrl(targetObjId, nextPage, pageSize);
	    		preQueryByAJAX("pagination!preQryByCache.action");	//進行預載
	    },    
	    error: function(data, status, e){     
	      alert("Ajax翻頁元件失敗 = " + e.message);                    
	    }
	 });
}

function preQueryByAJAX(url){
	//alert(url)
	if ( url!=null && url != "") {
		$.ajax({                                                 
			type: "POST",
			datatype:"html",    
			url: url,                                      
		    success: function(result){
		    		
		    },    
		    error: function(data, status, e){     
		      alert("預載查詢 Ajax翻頁元件失敗 = " + e.message);                    
		    }
		 });
	}
}

function refreshPaginationContent(targetObjId, totalSize, pageSize, totalPage, currentPage){
	$("#" + targetObjId + " input[name='currentPage']").val(currentPage);
	$("#" + targetObjId + " #currentPage_" + targetObjId ).val(currentPage);
	$("#" + targetObjId + " #pageSize_" + targetObjId ).val(pageSize);
	$("#" + targetObjId + " #totalSize_" + targetObjId ).val(totalSize);
	$("#" + targetObjId + " span[name='totalPage']").text(totalPage);
	$("#" + targetObjId + " span[name='totalSize']").text(totalSize);
	
	var startPageNo = ((Number(currentPage) - 1)) * pageSize + 1;
	var endPageNo = Number(startPageNo) + Number(pageSize) - 1;
	if(endPageNo > totalSize){
		endPageNo = totalSize;
	}
	$("#" + targetObjId + " span[name='startPageNo']").text(startPageNo);
	$("#" + targetObjId + " span[name='endPageNo']").text(endPageNo);
	//var numberLinkContent = "";
	//$("#" + targetObjId + " span[name='numberLink']").html(numberLinkContent)
	
}

/**
 * <b>全選/全不選</b>
 * @param	obj 			觸發此function的物件
 * @param 	targetObjName 	全選後，所需動作的checkbox name
 * @param 	chkArrayList 	儲存已被打勾的物件List的名稱，須為page control div中所設定的chkArrayList name
 * 
 * 使用範例：
 * <input type="checkbox" id="all" title="全選/全不選" onclick="chkAll(this, 'a', displayList);"/>
 */
function chkAll(obj, paginationType, targetObjId, chkArrayList, chkObjName){
	if(paginationType == 'normal'){
		chkAllByNormal(obj, targetObjId, chkArrayList, chkObjName);
	}else if(paginationType == 'ajax'){
		chkAllByAJAX(obj, targetObjId, chkArrayList, chkObjName);
	}
}

function chkAllByNormal(obj, targetObjId, chkArrayList, chkObjName){
	var currentPage = $("#" + targetObjId + " #currentPage_" + targetObjId ).val();
	var pageSize = $("#" + targetObjId + " #pageSize_" + targetObjId ).val();
	var startPageNo = (Number(currentPage) - 1) * Number(pageSize);
	var endPageNo = Number(startPageNo) + Number(pageSize) - 1;
//	alert("startPageNo = " + startPageNo + ", endPageNo = " + endPageNo);
	
	if(obj.checked){
		for(var i = startPageNo; i <= endPageNo; i++){
			$("#" + targetObjId + " #" + chkObjName + "_" + i).attr("checked", true);
			
//			var isExist = false;
//			for(var j = 0; j < chkArrayList.size(); j++){
//				if(chkArrayList.get(j) == $("#" + targetObjId + " #" + chkObjName + "_" + i).attr("value")){
//					isExist = true;
//				}
//			}
//			
//			if(!isExist){
//				chkArrayList.add($("#" + targetObjId + " #" + chkObjName + "_" + i).attr("value"));
//			}	
			
			if(!chkArrayList.contains($("#" + targetObjId + " #" + chkObjName + "_" + i).val())){
				chkArrayList.add($("#" + targetObjId + " #" + chkObjName + "_" + i).val());
			}

		}
	}else{
		for(var i = startPageNo; i <= endPageNo; i++){
			$("#" + targetObjId + " #" + chkObjName + "_" + i).attr("checked", false);
			for(var j = 0; j < chkArrayList.size(); j++){
				if(chkArrayList.get(j) == $("#" + targetObjId + " #" + chkObjName + "_" + i).val()){
					chkArrayList.remove(j);
					break;
				}
			}
		}
	}
}

function chkAllByAJAX(obj, targetObjId, chkArrayList, chkObjName){
	if(obj.checked){
		//當打勾時，名稱為targetObjName，皆會被打勾
		$("#" + targetObjId + " input[name='" + chkObjName + "']").each(function() {
			$(this).attr("checked", true);
			
//			var isExist = false;
//			for(var i = 0; i < chkArrayList.size(); i++){
//				if(chkArrayList.get(i) == $(this).attr("value")){
//					isExist = true;
//					break;
//				}
//			}
//			if(!isExist){
//				chkArrayList.add($(this).attr("value"));
//			}
			
			if(!chkArrayList.contains($(this).val())){
				chkArrayList.add($(this).val());
			}
	     });
	}else{
	     $("#" + targetObjId + " input[name='" + chkObjName + "']").each(function() {
	         $(this).attr("checked", false);
	         /*
				 * 因為chkArrayList.contains(obj.value)無法取得在陣列中的哪一個
				 * 所以無法正確刪除chkArrayList的位置
				 * 故無法使用jquery的function
				 */
	         for(var i = 0; i < chkArrayList.size(); i++){
				if(chkArrayList.get(i) == $(this).val()){
					chkArrayList.remove(i);
				}
			}
	     });
	}
}

/**
 * <b>將所選擇的物件存放至chkArrayList中或將所選擇的物件從chkArrayList中移除</b>
 * @param	obj 			觸發此function的物件
 * @param 	chkArrayList 	儲存已被打勾的物件List的名稱，須為page control div中所設定的chkArrayList name
 * 
 * 使用範例：
 * <input type="checkbox" id="a<s:property value="#cStatus.index" />" name="a" value="<s:property value="#displayList" />" onclick="chk(this, displayList);refreshChkAll(this.name, 'all');"/>
 */
function chk(obj, paginationType, targetObjId, chkArrayList, chkAllObjId){
	/*
	 * 因為chkArrayList.contains(obj.value)無法取得在陣列中的哪一個
	 * 所以無法正確刪除chkArrayList的位置
	 * 故無法使用jquery的function
	 */
	var isExist = false;
	for(var i = 0; i < chkArrayList.size(); i++){
		if(chkArrayList.get(i) == obj.value){
			if(obj.checked){
				isExist = true;
			}else{
				chkArrayList.remove(i);
			}
			break;
		}
	}
	if(obj.checked && !isExist){
		chkArrayList.add(obj.value);
	}
	refreshChkAll(paginationType, targetObjId, chkAllObjId, obj.name);
}

/**
  * <b>所選擇的物件是否對全選/全不選的物件進行勾選或取消勾選</b>
  * @param	objName			觸發此function的物件name
  * @param 	chkAllObjId 	全選/全不選的checkbox id
  * 
  * 使用範例：
  * <input type="checkbox" id="a<s:property value="#cStatus.index" />" name="a" value="<s:property value="#displayList" />" onclick="chk(this, displayList);refreshChkAll(this.name, 'all');"/>
  */
function refreshChkAll(paginationType, targetObjId, chkAllObjId, chkObjName){
	if(paginationType == "normal"){
		var currentPage = $("#" + targetObjId + " #currentPage_" + targetObjId ).val();
		var pageSize = $("#" + targetObjId + " #pageSize_" + targetObjId ).val();
		var totalSize = $("#" + targetObjId + " #totalSize_" + targetObjId ).val();
		var startPageNo = (Number(currentPage) - 1) * Number(pageSize);
		var endPageNo = Number(startPageNo) + Number(pageSize) - 1;
//		alert("startPageNo = " + startPageNo + ", endPageNo = " + endPageNo);

		var checkboxNum = 0;
		var checkNum = 0;
		for(var i = startPageNo; i <= endPageNo; i++){
			if(i < totalSize){
				checkboxNum++;
				if($("#" + targetObjId + " #" + chkObjName + "_" + i).attr('checked')){
					checkNum++;
				}
			}
		}
		
		if(checkboxNum == checkNum){
			$("#" + targetObjId + " #" + chkAllObjId).attr("checked", true);
		}else{
			$("#" + targetObjId + " #" + chkAllObjId).attr("checked", false);
		}
		
	}else if(paginationType == "ajax"){
		if($("#" + targetObjId + " input[name='" + chkObjName + "']").size() == $("#" + targetObjId + " input[name='" + chkObjName + "']:checked").size()){
			$("#" + targetObjId + " #" + chkAllObjId).attr("checked", true);
		}else{
			$("#" + targetObjId + " #" + chkAllObjId).attr("checked", false);
		}
	}
}

/**
  * <b>回到上一頁後, 還原當前頁面checkbox勾選之狀態</b>
  * @param	chkArrayList	儲存已被打勾的物件List的名稱，須為page control div中所設定的chkArrayList name
  * @param	chkAllObjId		全選/全不選的checkbox id
  * @param 	chkObjName 		所需動作的checkbox name
  * 
  * 使用範例：
  * refreshChk(displayList,  'all', 'a');
  */
function refreshChk(paginationType, targetObjId, chkArrayList, chkAllObjId, chkObjName){
	$("#" + targetObjId + " input[name='" + chkObjName + "']").each(function() {
		if(chkArrayList.contains($(this).val())){
	         $(this).attr("checked", true);
		}
     });
	refreshChkAll(paginationType, targetObjId, chkAllObjId, chkObjName);
}

/*
//goPage(id, 將前往的頁數)
function goPage(id, pageNum){
	var pageName = "pageName_"+id;
	var pageSizeId = "pageSize_"+id;
	var totalNumId = "totalNum_"+id;
	var totalPageId = "totalPage_"+id;
	var pageControlTypeId = "pageControlType_"+id;
	var pageControlDisplayTypeId = "pageControlDisplayType_"+id;
	updateUrl(pageName, pageNum);

	var pageSize = document.getElementById(pageSizeId).value;					//每頁顯示筆數
	var totalNum = document.getElementById(totalNumId).value;					//總筆數
	var totalPage = document.getElementById(totalPageId).value;				//總頁數
	var pageControlType = document.getElementById(pageControlTypeId).value;	//分頁控制元件型態
	var pageControlDisplayType = document.getElementById(pageControlDisplayTypeId).value;	//分頁控制元件型態

	var nowPgNoName = "nowPgNo_" + id;
	var pgNoName = "pgNo_" + id;

	var nowPgNoNameArray = getElementsByNameToIEFirefox("input", id, nowPgNoName);
	var pgNoNameArray = getElementsByNameToIEFirefox("input", id, pgNoName);

	if(pageControlDisplayType == "button"){
		var pgFirstName = "pgFirst_" + id;
		var pgPrevName = "pgPrev_" + id;
		var pgNextName = "pgNext_" + id;
		var pgLastName = "pgLast_" + id;
		
		var pgFirstNameArray = getElementsByNameToIEFirefox("input", id, pgFirstName);
		var pgPrevNameArray = getElementsByNameToIEFirefox("input", id, pgPrevName);
		var pgNextNameArray = getElementsByNameToIEFirefox("input", id, pgNextName);
		var pgLastNameArray = getElementsByNameToIEFirefox("input", id, pgLastName);
	}else{
		var pgFirstSpanShow = "pgFirstSpanShow_" + id;
		var pgPrevSpanShow = "pgPrevSpanShow_" + id;
		var pgNextSpanShow = "pgNextSpanShow_" + id;
		var pgLastSpanShow = "pgLastSpanShow_" + id;
		
		var pgFirstSpanHide = "pgFirstSpanHide_" + id;
		var pgPrevSpanHide = "pgPrevSpanHide_" + id;
		var pgNextSpanHide = "pgNextSpanHide_" + id;
		var pgLastSpanHide = "pgLastSpanHide_" + id;
		var pgNowNum = "pgNowNum_" + id;
		
		
		
		var pgFirstSpanShowArray = getElementsByNameToIEFirefox("span", id, pgFirstSpanShow);
		var pgPrevSpanShowArray = getElementsByNameToIEFirefox("span", id, pgPrevSpanShow);
		var pgNextSpanShowArray = getElementsByNameToIEFirefox("span", id, pgNextSpanShow);
		var pgLastSpanShowArray = getElementsByNameToIEFirefox("span", id, pgLastSpanShow);
		
		var pgFirstSpanHideArray = getElementsByNameToIEFirefox("span", id, pgFirstSpanHide);
		var pgPrevSpanHideArray = getElementsByNameToIEFirefox("span", id, pgPrevSpanHide);
		var pgNextSpanHideArray = getElementsByNameToIEFirefox("span", id, pgNextSpanHide);
		var pgLastSpanHideArray = getElementsByNameToIEFirefox("span", id, pgLastSpanHide);
		
		var pgNowNumArray = getElementsByNameToIEFirefox("input", id, pgNowNum);
	}
	
	var pageFormId = "pageForm_" + id;
	
	var newStart;
	var newEnd;
	
	if(Number(pageNum)>Number(totalPage)){
		pageNum=totalPage;
	}else if(Number(pageNum)<1){
		pageNum=1;
	}
	
	newStart=(Number(pageNum)-1)*Number(pageSize);
	newEnd=Number(newStart)+Number(pageSize);
	if(newEnd>totalNum){
		newEnd=totalNum;
	}
	//alert("newStart="+newStart);
	//alert("newEnd="+newEnd);
	
	if(pageControlType=="tr"){
		for(var i=newStart;i<newEnd;i++){
			if(i<totalNum){
				var openTrId=id+"_"+i;
				document.getElementById(openTrId).style.display="";
			}
		}
		
		var oldPageNum=document.getElementsByName(nowPgNoName)[0].value;
		var oldStart=(Number(oldPageNum)-1)*Number(pageSize);
		var oldEnd=Number(oldStart)+Number(pageSize);
		//alert("oldStart="+oldStart);
		//alert("oldEnd="+oldEnd);
		if(oldStart!=newStart){
			for(var i=oldStart;i<oldEnd;i++){
				if(i<totalNum){
					var closeTrId=id+"_"+i;
					document.getElementById(closeTrId).style.display="none";
				}
			}
		}
		
		if(newStart!=0){
			for(var i=0;i<Number(pageSize);i++){
				if(i<totalNum){
					var closeTrId=id+"_"+i;
					document.getElementById(closeTrId).style.display="none";
				}
			}
		}
	}else if(pageControlType=="div"){
		var openDivId=id+"_"+(Number(pageNum)-1);
		document.getElementById(openDivId).style.display="";
		if(pageNum!=nowPgNoNameArray[0].value){
			var closeDivId=id+"_"+(Number(nowPgNoNameArray[0].value)-1);
			document.getElementById(closeDivId).style.display="none";
		}
	}
	
	//上下兩列的顯示頁數
	for(var x=0; x<pgNoNameArray.length; x++){
		pgNoNameArray[x].value= pageNum;
	    nowPgNoNameArray[x].value = pageNum;
	    nowPgNoNameArray[x].style.width = 10 * pageNum.toString().length +"px";
	    if(pageControlDisplayType=="link"){
	    	pgNowNumArray[x].value=(Number(newStart)+1)+" - "+Number(newEnd);
	    }
	}
	
	//上下兩列的顯示頁數(如果頁數為1時，"第一頁"和"上一頁"不顯示)
	if(pageNum==1){
		if(pageControlDisplayType=="button"){
			for(var j=0; j<pgFirstNameArray.length; j++){
				pgFirstNameArray[j].disabled="disabled";
			    pgPrevNameArray[j].disabled="disabled";
			}
		}else if(pageControlDisplayType=="link"){
			for(var j=0; j<pgFirstSpanShowArray.length; j++){
				//pgFirstSpanArray[j].innerHTML="第一頁";
				//pgPrevSpanArray[j].innerHTML="上一頁";
				pgFirstSpanShowArray[j].style.display = "none";
				pgPrevSpanShowArray[j].style.display = "none";
				pgFirstSpanHideArray[j].style.display = "";
				pgPrevSpanHideArray[j].style.display = "";
			}
		}
	}else{
		if(pageControlDisplayType=="button"){
			for(var j=0; j<pgFirstNameArray.length; j++){
				pgFirstNameArray[j].disabled="";
				pgPrevNameArray[j].disabled="";
			}
		}else if(pageControlDisplayType=="link"){
			for(var j=0; j<pgFirstSpanShowArray.length; j++){
				//pgFirstSpanArray[j].innerHTML="<a href=\"javascript:\" id=\"pgFirst_"+id+"\" name=\"pgFirst_"+id+"\" onclick=\"goPage('"+id+"', 1);\">第一頁</a>";
			    //pgPrevSpanArray[j].innerHTML="<a href=\"javascript:\" id=\"pgPrev_"+id+"\" name=\"pgPrev_"+id+"\" onclick=\"goPage('"+id+"', Number(document."+pageFormId+"["+j+"].pgNo_"+id+".value)-1);\">上一頁</a>";
				pgFirstSpanShowArray[j].style.display = "";
				pgPrevSpanShowArray[j].style.display = "";
				pgFirstSpanHideArray[j].style.display = "none";
				pgPrevSpanHideArray[j].style.display = "none";
			}
		}
		
	}

	//上下兩列的顯示頁數(如果頁數為最後一頁時，"最後一頁"和"下一頁"不顯示)
	if(pageNum==totalPage){
		if(pageControlDisplayType=="button"){
			for(var j=0; j<pgLastNameArray.length; j++){
			    pgNextNameArray[j].disabled="disabled";
			    pgLastNameArray[j].disabled="disabled";
			}
		}else if(pageControlDisplayType=="link"){
			for(var j=0; j<pgLastSpanShowArray.length; j++){
				//pgNextSpanArray[j].innerHTML="下一頁";
				//pgLastSpanArray[j].innerHTML="最後一頁";
				pgNextSpanShowArray[j].style.display = "none";
				pgLastSpanShowArray[j].style.display = "none";
				pgNextSpanHideArray[j].style.display = "";
				pgLastSpanHideArray[j].style.display = "";
			}
		}
	}else{
		if(pageControlDisplayType=="button"){
			for(var j=0; j<pgLastNameArray.length; j++){
				pgNextNameArray[j].disabled="";
			    pgLastNameArray[j].disabled="";
			}
		}else if(pageControlDisplayType=="link"){
			for(var j=0; j<pgLastSpanShowArray.length; j++){
				//pgNextSpanArray[j].innerHTML="<a href=\"javascript:\" id=\"pgNext_"+id+"\" name=\"pgNext_"+id+"\" onclick=\"goPage('"+id+"', Number(document."+pageFormId+"["+j+"].pgNo_"+id+".value)+1);\">下一頁</a>";
			    //pgLastSpanArray[j].innerHTML="<a href=\"javascript:\" id=\"pgLast_"+id+"\" name=\"pgLast_"+id+"\" onclick=\"goPage('"+id+"', "+totalPage+");\">最後一頁</a>";
				pgNextSpanShowArray[j].style.display = "";
				pgLastSpanShowArray[j].style.display = "";
				pgNextSpanHideArray[j].style.display = "none";
				pgLastSpanHideArray[j].style.display = "none";
			}
		}
		
	}
	
	if(document.getElementById("checkAll_"+id)!=null){
		var checkNum=0;
		var checkYNum=0;
		var checkDeleteName="checkDelete_"+id;
		for(var i=newStart;i<newEnd;i++){
			if(i<totalNum){
				checkNum++;
				if(document.getElementsByName(checkDeleteName)[i].checked){
					checkYNum++;
				}
			}
		}
		if(checkNum==checkYNum){
			document.getElementById("checkAll_"+id).checked="checked";
		}else{
			document.getElementById("checkAll_"+id).checked="";
		}
	}
}

function checkAll(id, obj){
	var pageSizeId="pageSize_"+id;
	var totalNumId="totalNum_"+id;
	var nowPgNoName="nowPgNo_"+id;
	var pageSize=document.getElementById(pageSizeId).value;					//每頁顯示筆數
	var totalNum=document.getElementById(totalNumId).value;					//總筆數
	var nowPgNo=document.getElementsByName(nowPgNoName)[0].value;
	
	var checkStart=(Number(nowPgNo)-1)*Number(pageSize);
	var checkEnd=Number(checkStart)+Number(pageSize);
	if(checkEnd>totalNum){
		checkEnd=totalNum;
	}
	
	var checkDeleteName="checkDelete_"+id;
	for(var i=checkStart;i<checkEnd;i++){
		if(i<totalNum){
			if(document.getElementsByName(checkDeleteName)[i].disabled == false && obj.checked){
				document.getElementsByName(checkDeleteName)[i].checked="checked";
			}else{
				document.getElementsByName(checkDeleteName)[i].checked="";
			}	
		}
	}
}

function deleteCheck(id){
	var pageSizeId="pageSize_"+id;
	var totalNumId="totalNum_"+id;
	var nowPgNoName="nowPgNo_"+id;
	var pageSize=document.getElementById(pageSizeId).value;					//每頁顯示筆數
	var totalNum=document.getElementById(totalNumId).value;					//總筆數
	var nowPgNo=document.getElementsByName(nowPgNoName)[0].value;
	
	var checkStart=(Number(nowPgNo)-1)*Number(pageSize);
	var checkEnd=Number(checkStart)+Number(pageSize);
	if(checkEnd>totalNum){
		checkEnd=totalNum;
	}
	
	var checkNum=0;
	var checkYNum=0;
	var checkDeleteName="checkDelete_"+id;
	for(var i=checkStart;i<checkEnd;i++){
		if(i<totalNum){
			if(document.getElementsByName(checkDeleteName)[i].disabled == false){
				checkNum++;
			}
			if(document.getElementsByName(checkDeleteName)[i].disabled == false && document.getElementsByName(checkDeleteName)[i].checked){
				checkYNum++;
			}
		}
	}
	if(checkNum==checkYNum){
		document.getElementById("checkAll_"+id).checked="checked";
	}else{
		document.getElementById("checkAll_"+id).checked="";
	}
}

function getElementsByNameToIEFirefox(tag, id, name) {
	var pageDivStart = "pageDivStart_" + id;
	var pageDivEnd = "pageDivEnd_" + id;

	var arr = new Array();
	var arrNum = 0;
	
	var elem_start = document.getElementById(pageDivStart).getElementsByTagName(tag);
	
	for(var i = 0; i < elem_start.length; i++) {
		var att = elem_start[i].getAttribute("name");
		if(att == name) {
			arr[arrNum] = elem_start[i];
			arrNum++;
		}
	}
	
	var elem_end = document.getElementById(pageDivEnd).getElementsByTagName(tag);
	for(var i = 0; i < elem_end.length; i++) {
		var att = elem_end[i].getAttribute("name");
		if(att == name) {
			arr[arrNum] = elem_end[i];
			arrNum++;
		}
	}
	
	return arr;
}
*/

//分析url
function parseURL(url) {
	var a = document.createElement('a');
	a.href = url;
	return {
		source: url,
		protocol: a.protocol.replace(':', ''),
		host: a.hostname,
		port: a.port,
		query: a.search,
		params: (function () {
					var ret = {},
					seg = a.search.replace(/^\?/, '').split('&'),
					len = seg.length, i = 0, s;
					for (; i < len; i++) {
						if (!seg[i]) { continue; }
						s = seg[i].split('=');
						ret[s[0]] = s[1];
					}
					return ret;
				})(),
		file: (a.pathname.match(/\/([^\/?#]+)$/i) || [, ''])[1],
		//hash: a.hash.replace('#', ''),
		hash: (function () {
					var ret = {},
					seg = a.hash.replace(/^\#/, '').split('&'),
					len = seg.length, i = 0, s;
					for (; i < len; i++) {
						if (!seg[i]) { continue; }
						s = seg[i].split('=');
						ret[s[0]] = s[1];
					}
					return ret;
				})(),
		path: a.pathname.replace(/^([^\/])/, '/$1'),
		relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [, ''])[1],
		segments: a.pathname.replace(/^\//, '').split('/')
	};
}

function replaceUrlParams(myUrl, newParams, newParamsValue){
	var hasInMyUrlParams = false;
	for (var x in myUrl.haha) {
		if (newParams.toLowerCase() == x.toLowerCase()) {
			myUrl.hash[x] = newParamsValue;
			hasInMyUrlParams = true;
			break;
		}
	}
	if (!hasInMyUrlParams) {
		myUrl.hash[newParams] = newParamsValue;
	}
	
	var _result = myUrl.protocol + "://" + myUrl.host + ":" + myUrl.port + myUrl.path ;

	if (myUrl.query != "") {
		_result +=  myUrl.query;
	}
	
	if (myUrl.hash != "") {
		_result += "#" ;
	}
	
	for (var p in myUrl.hash) {
		_result += (p + "=" + myUrl.hash[p] + "&");
	}

	if (_result.substr(_result.length - 1) == "&") {
		_result = _result.substr(0, _result.length - 1);
	}
	

	//if (myUrl.hash != "") {
	//	_result += "#" + myUrl.hash;
	//}
	
	return _result;
}

//
function updateUrl(targetObjId, currentPage, pageSize){
	var _myURL;
	var _newUrl;
	var paginationPage = "paginationPage_" + targetObjId;
	var paginationSize = "paginationSize_" + targetObjId;
	_myURL = parseURL(String(location));
//	_newUrl = replaceUrlParams(_myURL, paginationPage, currentPage );
//	location =_newUrl;
//	_myURL = parseURL(String(location));
//	_newUrl = replaceUrlParams(_myURL, paginationSize, pageSize );
//	location =_newUrl;
	_newUrl = replaceUrlParams(_myURL, paginationPage, currentPage, paginationSize, pageSize);
	location =_newUrl;
}

function replaceUrlParams(myUrl, paginationPage, currentPage, paginationSize, pageSize){
	
	var hasInMyUrlParams = false;
	for (var x in myUrl.haha) {
		if (paginationPage.toLowerCase() == x.toLowerCase()) {
			myUrl.hash[x] = paginationPage;
			hasInMyUrlParams = true;
			break;
		}
	}
	
	if (!hasInMyUrlParams) {
		myUrl.hash[paginationPage] = currentPage;
		myUrl.hash[paginationSize] = pageSize;
	}
	
	var _result = myUrl.protocol + "://" + myUrl.host + ":" + myUrl.port + myUrl.path ;
	
	if (myUrl.query != "") {
		_result +=  myUrl.query;
	}
	
	if (myUrl.hash != "") {
		_result += "#" ;
	}
	
	for (var p in myUrl.hash) {
		_result += (p + "=" + myUrl.hash[p] + "&" );
	}

	if (_result.substr(_result.length - 1) == "&") {
		_result = _result.substr(0, _result.length - 1);
	}
	

	//if (myUrl.hash != "") {
	//	_result += "#" + myUrl.hash;
	//}
	
	return _result;
}

//function updateUrl(urlParams, urlParamsValue){
//	var myURL = parseURL(String(location));
//	var _newUrl = replaceUrlParams(myURL, urlParams, urlParamsValue );
//	location =_newUrl;
//}

